$(function() {
	manyValues();
	
	// $(".btn2").on('click',function(){
	// 	console.log(124333)
	// })

})


//接收多值
function manyValues() {
	var url = decodeURI(window.location.search);
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		var key = new Array(strs.length);
		var value = new Array(strs.length);
		for (i = 0; i < strs.length; i++) {
			key[i] = strs[i].split("=")[0]
			value[i] = unescape(strs[i].split("=")[1]);
			// console.log(key[i]+"="+value[i]);
		}
		// console.log(value[1])
		var code = "订单号：" + value[0];
		var key = value[1];
		if (key == 1) {
			$(".daifu .left").html("待付款");
			$(".time").html("您的订单到" + value[2] + "即将结束，超时后订单将自动取消，请您尽快付款")
			// document.getElementsByClassName("span").style.color = "blue";
			// $(".progressBar span").style.color="red"S

		} else if (key == 2) {
			$(".daifu .left").html("已付款");
			$(".daifu .right").hide(500);
			$(".time").html("您已付过款啦，我们会尽快安排发货哦！")
			console.log("已付款")
		} else if (key == 3) {
			$(".time").html("包裹已经给您送达，请您尽快签收！")
			console.log("待收货")
		} else {
			$(".time").html("交易已经完成！")
			console.log("交易关闭")
		}


		$.ajax({
			type: 'post',
			url: 'http://localhost:8080/mall/findOrderDetailsById?orders_id=' + value[0],
			contentType: 'application/json',
			success: function(result) {
				var str = ``;
				var data1 = result.message
				// console.log(data1)
				for (var j = 0; j < data1.length; j++) {
					str +=
						`
							<div class="cart-item-list">
								<div class="cart-item check-cart-item">
									<div class="p-goods">
										<div class="p-img">
											<img src="${data1[j].itemImage}" alt="">
										</div>
										<div class="p-msg">${data1[j].itemTitle}</div>
									</div>
									<div class="p-price">${data1[j].itemPrice}</div>
									<div class="p-num">
										<div class="quantity-form">
											${data1[j].itemNum}
										</div>
									</div>
									<div class="p-sum">${data1[j].total}</div>
								</div>
							</div>
							<div class="cart-floatbar">
								<div class="toolbar-right">
									<div class="price-sum">应付金额： <em>${data1[j].total}</em></div>
								</div>
							</div>
							
						`

				}
				$(".carbody").html(str)
			}
		})


		$.ajax({
			type: 'post',
			url: 'http://localhost:8080/mall/findAddressById?id=' + value[3],
			contentType: 'application/json',
			success: function(result) {
				var str1 = ``;
				var data2 = result.message
				// console.log(data2[0].name)
				
					str1 += `
				  			<div>姓名：${data2[0].name}</div>
				  			<div>联系电话：${data2[0].tel}</div>
				  			<div>详细地址：${data2[0].address}</div>				
				  							
				  		`
				
				$(".message").html(str1)
				
			}
		})
		
		$(".btn2").on('click',function(){
			$.ajax({
				url: "http://localhost:8080/mall/deleteOrder?order_code="+value[0],
				dataType: "json",
				success: function(result) {
					location.reload();
				}
			})
		})
		




	}
	$(".title").html(code);




}









// function oneValues() {
// 	var result;
// 	var url = window.location.search; //获取url中"?"符后的字串  
// 	if (url.indexOf("?") != -1) {
// 		code = url.substr(url.indexOf("=") + 1);
// 		result = "订单号：" + code
// 	}
// 	return result;

// }
